/**
 * 
 */
package wong.board.client.widgets;

import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;

/**
 * @author wong
 * 
 */
public class Link extends Component {

	private AnchorElement anchor;

	private Link() {
		this.setStyleName(css.link());
	}

	public Link(String label, String url) {
		this();
		setLink(label, url);
	}

	public Link(String label, String url, String tooltip) {
		this(label, url);
		setTitle(tooltip);
	}

	@Override
	protected Element createElement() {
		anchor = Document.get().createAnchorElement();
		return anchor;
	}

	public void setLink(String label, String url) {
		anchor.setHref(url);
		anchor.setTarget("_blank");
		anchor.setTitle("open in new window: " + url);
		anchor.setInnerText(label);
	}
}
